

<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
  <meta charset="utf-8" />
  <meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />

  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  
  <title>RBD 镜像 &mdash; Ceph Documentation</title>
  

  
  <link rel="stylesheet" href="../../_static/ceph.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/ceph.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/graphviz.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/css/custom.css" type="text/css" />

  
  

  
  

  

  
  <!--[if lt IE 9]>
    <script src="../../_static/js/html5shiv.min.js"></script>
  <![endif]-->
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="../../" src="../../_static/documentation_options.js"></script>
        <script src="../../_static/jquery.js"></script>
        <script src="../../_static/_sphinx_javascript_frameworks_compat.js"></script>
        <script data-url_root="../../" id="documentation_options" src="../../_static/documentation_options.js"></script>
        <script src="../../_static/doctools.js"></script>
        <script src="../../_static/sphinx_highlight.js"></script>
    
    <script type="text/javascript" src="../../_static/js/theme.js"></script>

    
    <link rel="index" title="Index" href="../../genindex/" />
    <link rel="search" title="Search" href="../../search/" />
    <link rel="next" title="映像在线迁移" href="../rbd-live-migration/" />
    <link rel="prev" title="RBD Exclusive Locks" href="../rbd-exclusive-locks/" /> 
</head>

<body class="wy-body-for-nav">

   
  <header class="top-bar">
    <div role="navigation" aria-label="Page navigation">
  <ul class="wy-breadcrumbs">
      <li><a href="../../" class="icon icon-home" aria-label="Home"></a></li>
          <li class="breadcrumb-item"><a href="../">Ceph 块设备</a></li>
          <li class="breadcrumb-item"><a href="../rbd-operations/">Ceph 块设备运维</a></li>
      <li class="breadcrumb-item active">RBD 镜像</li>
      <li class="wy-breadcrumbs-aside">
            <a href="../../_sources/rbd/rbd-mirroring.rst.txt" rel="nofollow"> View page source</a>
      </li>
  </ul>
  <hr/>
</div>
  </header>
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search"  style="background: #eee" >
          

          
            <a href="../../" class="icon icon-home"> Ceph
          

          
          </a>

          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../search/" method="get">
    <input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        
        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../../start/">Ceph 简介</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../install/">安装 Ceph</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../cephadm/">Cephadm</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../rados/">Ceph 存储集群</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../cephfs/">Ceph 文件系统</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../">Ceph 块设备</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="../rados-rbd-cmds/">基本命令</a></li>
<li class="toctree-l2 current"><a class="reference internal" href="../rbd-operations/">运维</a><ul class="current">
<li class="toctree-l3"><a class="reference internal" href="../rbd-snapshot/">快照</a></li>
<li class="toctree-l3"><a class="reference internal" href="../rbd-exclusive-locks/">互斥锁、独占锁</a></li>
<li class="toctree-l3 current"><a class="current reference internal" href="#">镜像</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#id1">存储池配置</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id7">映像配置</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id12">镜像状态</a></li>
<li class="toctree-l4"><a class="reference internal" href="#rbd-mirror">rbd-mirror 守护进程</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="../rbd-live-migration/">实时迁移</a></li>
<li class="toctree-l3"><a class="reference internal" href="../rbd-persistent-read-only-cache/">永久只读缓存</a></li>
<li class="toctree-l3"><a class="reference internal" href="../rbd-persistent-write-log-cache/">永久写日志缓存</a></li>
<li class="toctree-l3"><a class="reference internal" href="../rbd-encryption/">加密</a></li>
<li class="toctree-l3"><a class="reference internal" href="../rbd-config-ref/">配置选项 (librbd)</a></li>
<li class="toctree-l3"><a class="reference internal" href="../rbd-replay/">RBD 重放</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../rbd-integrations/">对接</a></li>
<li class="toctree-l2"><a class="reference internal" href="../man/">手册页</a></li>
<li class="toctree-l2"><a class="reference internal" href="../api/">APIs</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../radosgw/">Ceph 对象网关</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../mgr/">Ceph 管理器守护进程</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../mgr/dashboard/">Ceph 仪表盘</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../monitoring/">监控概览</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../api/">API 文档</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../architecture/">体系结构</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../dev/developer_guide/">开发者指南</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../dev/internals/">Ceph 内幕</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../governance/">项目管理</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../foundation/">Ceph 基金会</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../ceph-volume/">ceph-volume</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../releases/general/">Ceph 版本（总目录）</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../releases/">Ceph 版本（索引）</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../security/">Security</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../hardware-monitoring/">硬件监控</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../glossary/">Ceph 术语</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../jaegertracing/">Tracing</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../translation_cn/">中文版翻译资源</a></li>
</ul>

            
          
        </div>
        
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../../">Ceph</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
<div id="dev-warning" class="admonition note">
  <p class="first admonition-title">Notice</p>
  <p class="last">This document is for a development version of Ceph.</p>
</div>
  <div id="docubetter" align="right" style="padding: 5px; font-weight: bold;">
    <a href="https://pad.ceph.com/p/Report_Documentation_Bugs">Report a Documentation Bug</a>
  </div>

  
  <section id="rbd">
<h1>RBD 镜像<a class="headerlink" href="#rbd" title="Permalink to this heading"></a></h1>
<p id="index-0">RBD 映像可在两个 Ceph 集群间异步地镜像。此能力有两种模式可用：</p>
<ul class="simple">
<li><p><strong>Journal-based</strong>: This mode uses the RBD journaling image feature to ensure
point-in-time, crash-consistent replication between clusters. Every write to
the RBD image is first recorded to the associated journal before modifying the
actual image. The remote cluster will read from this associated journal and
replay the updates to its local copy of the image. Since each write to the
RBD image will result in two writes to the Ceph cluster, expect write
latencies to nearly double while using the RBD journaling image feature.</p></li>
<li><p><strong>Snapshot-based</strong>: This mode uses periodically scheduled or manually
created RBD image mirror-snapshots to replicate crash-consistent RBD images
between clusters. The remote cluster will determine any data or metadata
updates between two mirror-snapshots and copy the deltas to its local copy of
the image. With the help of the RBD <code class="docutils literal notranslate"><span class="pre">fast-diff</span></code> image feature, updated data
blocks can be quickly determined without the need to scan the full RBD image.
Since this mode is not as fine-grained as journaling, the complete delta
between two snapshots will need to be synced prior to use during a failover
scenario. Any partially applied set of deltas will be rolled back at moment
of failover.</p></li>
</ul>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>journal-based mirroring requires the Ceph Jewel release or later;
snapshot-based mirroring requires the Ceph Octopus release or later.</p>
</div>
<p>Mirroring is configured on a per-pool basis within peer clusters and can be
configured on a specific subset of images within the pool.  You can also mirror
all images within a given pool when using journal-based
mirroring. Mirroring is configured using the <code class="docutils literal notranslate"><span class="pre">rbd</span></code> command. The
<code class="docutils literal notranslate"><span class="pre">rbd-mirror</span></code> daemon is responsible for pulling image updates from the remote
peer cluster and applying them to the image within the local cluster.</p>
<p>Depending on the desired needs for replication, RBD mirroring can be configured
for either one- or two-way replication:</p>
<ul class="simple">
<li><p><strong>单向复制（ One-way Replication ）</strong>: 数据只是从主集群镜像到次集群时，
<code class="docutils literal notranslate"><span class="pre">rbd-mirror</span></code> 守护进程只需在次集群上运行。</p></li>
<li><p><strong>双向复制（ Two-way Replication ）</strong>: 数据从一个集群的主映像镜像到另一个集群的非主映像时（反之亦然），两个集群上都得运行 <code class="docutils literal notranslate"><span class="pre">rbd-mirror</span></code> 守护进程。</p></li>
</ul>
<div class="admonition important">
<p class="admonition-title">Important</p>
<p>每一个 <code class="docutils literal notranslate"><span class="pre">rbd-mirror</span></code> 都必须能够同时连接本地和远端 Ceph 集群
（即所有监视器和 OSD 主机）。另外，两个数据中心之间的网络必须有足够的带宽，
以处理镜像流量。</p>
</div>
<section id="id1">
<h2>存储池配置<a class="headerlink" href="#id1" title="Permalink to this heading"></a></h2>
<p>以下步骤演示了如何用 <code class="docutils literal notranslate"><span class="pre">rbd</span></code> 命令执行基本的管理任务，并配置镜像。镜像是以 Ceph 集群的存储池为单位配置的。</p>
<p>以下的存储池配置步骤在两个互联集群上都要执行一次。这些步骤假设有两个集群，为清晰起见，分别命名为 local 和 remote ，二者都可以从一台主机访问。</p>
<p>关于如何连接到不同的 Ceph 集群，请参考 <a class="reference external" href="../../man/8/rbd">rbd</a> 手册页。</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>以下实例中的集群名对应着同名的 Ceph 配置文件（
如 <code class="docutils literal notranslate"><span class="pre">/etc/ceph/site-b.conf</span></code> ）。如何配置多个集群请参考
<a class="reference external" href="../../rados/configuration/ceph-conf/#running-multiple-clusters">ceph-conf</a> 文档。注意， <code class="docutils literal notranslate"><span class="pre">rbd-mirror</span></code> <strong>不要求</strong>
源和目的集群有唯一的内部名称，都可以、而且都应该叫
<code class="docutils literal notranslate"><span class="pre">ceph</span></code> 。 <code class="docutils literal notranslate"><span class="pre">rbd-mirror</span></code> 需要的配置 <cite>files</cite> 所指的本地和远程集群可以任意命名，另外，把守护进程容器化也是一个在 <code class="docutils literal notranslate"><span class="pre">/etc/ceph</span></code> 之外运营集群以避免混淆的策略。</p>
</div>
<section id="id2">
<h3>启用镜像功能<a class="headerlink" href="#id2" title="Permalink to this heading"></a></h3>
<p>要用 <code class="docutils literal notranslate"><span class="pre">rbd</span></code> 命令启用存储池的镜像功能，可指定
<code class="docutils literal notranslate"><span class="pre">mirror</span> <span class="pre">pool</span> <span class="pre">enable</span></code> 命令、存储池名字、镜像模式、和一个可选的站点名（用于描述本地集群）:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">rbd</span> <span class="n">mirror</span> <span class="n">pool</span> <span class="n">enable</span> <span class="p">[</span><span class="o">--</span><span class="n">site</span><span class="o">-</span><span class="n">name</span> <span class="p">{</span><span class="n">local</span><span class="o">-</span><span class="n">site</span><span class="o">-</span><span class="n">name</span><span class="p">}]</span> <span class="p">{</span><span class="n">pool</span><span class="o">-</span><span class="n">name</span><span class="p">}</span> <span class="p">{</span><span class="n">mode</span><span class="p">}</span>
</pre></div>
</div>
<p>其中，镜像模式可以是 <code class="docutils literal notranslate"><span class="pre">image</span></code> 或 <code class="docutils literal notranslate"><span class="pre">pool</span></code> ：</p>
<ul class="simple">
<li><p><strong>image</strong>: 配置为 <code class="docutils literal notranslate"><span class="pre">image</span></code> 模式时，需<a class="reference external" href="#enable-image-mirroring">显式地开启</a>各个镜像的镜像功能。</p></li>
<li><p><strong>pool</strong> （默认的）: 配置为 <code class="docutils literal notranslate"><span class="pre">pool</span></code> 模式时，存储池内所有启用了 journaling 功能的映像都会被镜像。</p></li>
</ul>
<p>例如:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ rbd --cluster site-a mirror pool enable --site-name site-a image-pool image
$ rbd --cluster site-b mirror pool enable --site-name site-b image-pool image
</pre></div>
</div>
<p>创建或导入一个新的 <a class="reference external" href="#bootstrap-peers">自举引导令牌</a> 时也可以指定站点名。</p>
<p>The site name can be changed later using the same <code class="docutils literal notranslate"><span class="pre">mirror</span> <span class="pre">pool</span> <span class="pre">enable</span></code>
subcommand but note that the local site name and the corresponding site name
used by the remote cluster generally must match.</p>
</section>
<section id="id3">
<h3>禁用镜像功能<a class="headerlink" href="#id3" title="Permalink to this heading"></a></h3>
<p>要用 <code class="docutils literal notranslate"><span class="pre">rbd</span></code> 命令禁用存储池的镜像功能，可指定
<code class="docutils literal notranslate"><span class="pre">mirror</span> <span class="pre">pool</span> <span class="pre">disable</span></code> 命令和存储池名字：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">rbd</span> <span class="n">mirror</span> <span class="n">pool</span> <span class="n">disable</span> <span class="p">{</span><span class="n">pool</span><span class="o">-</span><span class="n">name</span><span class="p">}</span>
</pre></div>
</div>
<p>用这个方法禁用一个存储池的镜像功能时，此存储池内所有明确启用了镜像功能的所有映像，其镜像功能都会被禁用。</p>
<p>例如：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ rbd --cluster site-a mirror pool disable image-pool
$ rbd --cluster site-b mirror pool disable image-pool
</pre></div>
</div>
</section>
<section id="bootstrap-peers">
<h3>Bootstrap Peers<a class="headerlink" href="#bootstrap-peers" title="Permalink to this heading"></a></h3>
<p>In order for the <code class="docutils literal notranslate"><span class="pre">rbd-mirror</span></code> daemon to discover its peer cluster, the peer
must be registered and a user account must be created.
This process can be automated with <code class="docutils literal notranslate"><span class="pre">rbd</span></code> and the
<code class="docutils literal notranslate"><span class="pre">mirror</span> <span class="pre">pool</span> <span class="pre">peer</span> <span class="pre">bootstrap</span> <span class="pre">create</span></code> and <code class="docutils literal notranslate"><span class="pre">mirror</span> <span class="pre">pool</span> <span class="pre">peer</span> <span class="pre">bootstrap</span> <span class="pre">import</span></code>
commands.</p>
<p>To manually create a new bootstrap token with <code class="docutils literal notranslate"><span class="pre">rbd</span></code>, issue the
<code class="docutils literal notranslate"><span class="pre">mirror</span> <span class="pre">pool</span> <span class="pre">peer</span> <span class="pre">bootstrap</span> <span class="pre">create</span></code> subcommand, a pool name, and an
optional friendly site name to describe the local cluster:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">rbd</span> <span class="n">mirror</span> <span class="n">pool</span> <span class="n">peer</span> <span class="n">bootstrap</span> <span class="n">create</span> <span class="p">[</span><span class="o">--</span><span class="n">site</span><span class="o">-</span><span class="n">name</span> <span class="p">{</span><span class="n">local</span><span class="o">-</span><span class="n">site</span><span class="o">-</span><span class="n">name</span><span class="p">}]</span> <span class="p">{</span><span class="n">pool</span><span class="o">-</span><span class="n">name</span><span class="p">}</span>
</pre></div>
</div>
<p>The output of <code class="docutils literal notranslate"><span class="pre">mirror</span> <span class="pre">pool</span> <span class="pre">peer</span> <span class="pre">bootstrap</span> <span class="pre">create</span></code> will be a token that should
be provided to the <code class="docutils literal notranslate"><span class="pre">mirror</span> <span class="pre">pool</span> <span class="pre">peer</span> <span class="pre">bootstrap</span> <span class="pre">import</span></code> command. 例如,
on site-a:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ rbd --cluster site-a mirror pool peer bootstrap create --site-name site-a image-pool
eyJmc2lkIjoiOWY1MjgyZGItYjg5OS00NTk2LTgwOTgtMzIwYzFmYzM5NmYzIiwiY2xpZW50X2lkIjoicmJkLW1pcnJvci1wZWVyIiwia2V5IjoiQVFBUnczOWQwdkhvQmhBQVlMM1I4RmR5dHNJQU50bkFTZ0lOTVE9PSIsIm1vbl9ob3N0IjoiW3YyOjE5Mi4xNjguMS4zOjY4MjAsdjE6MTkyLjE2OC4xLjM6NjgyMV0ifQ==
</pre></div>
</div>
<p>To manually import the bootstrap token created by another cluster with <code class="docutils literal notranslate"><span class="pre">rbd</span></code>,
specify the <code class="docutils literal notranslate"><span class="pre">mirror</span> <span class="pre">pool</span> <span class="pre">peer</span> <span class="pre">bootstrap</span> <span class="pre">import</span></code> command, the pool name, a file
path to the created token (or ‘-’ to read from standard input), along with an
optional friendly site name to describe the local cluster and a mirroring
direction (defaults to rx-tx for bidirectional mirroring, but can also be set
to rx-only for unidirectional mirroring):</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">rbd</span> <span class="n">mirror</span> <span class="n">pool</span> <span class="n">peer</span> <span class="n">bootstrap</span> <span class="kn">import</span> <span class="p">[</span><span class="o">--</span><span class="n">site</span><span class="o">-</span><span class="n">name</span> <span class="p">{</span><span class="n">local</span><span class="o">-</span><span class="n">site</span><span class="o">-</span><span class="n">name</span><span class="p">}]</span> <span class="p">[</span><span class="o">--</span><span class="n">direction</span> <span class="p">{</span><span class="n">rx</span><span class="o">-</span><span class="n">only</span> <span class="ow">or</span> <span class="n">rx</span><span class="o">-</span><span class="n">tx</span><span class="p">}]</span> <span class="p">{</span><span class="n">pool</span><span class="o">-</span><span class="n">name</span><span class="p">}</span> <span class="p">{</span><span class="n">token</span><span class="o">-</span><span class="n">path</span><span class="p">}</span>
</pre></div>
</div>
<p>例如，在 site-b 上：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ cat &lt;&lt;EOF &gt; token
eyJmc2lkIjoiOWY1MjgyZGItYjg5OS00NTk2LTgwOTgtMzIwYzFmYzM5NmYzIiwiY2xpZW50X2lkIjoicmJkLW1pcnJvci1wZWVyIiwia2V5IjoiQVFBUnczOWQwdkhvQmhBQVlMM1I4RmR5dHNJQU50bkFTZ0lOTVE9PSIsIm1vbl9ob3N0IjoiW3YyOjE5Mi4xNjguMS4zOjY4MjAsdjE6MTkyLjE2OC4xLjM6NjgyMV0ifQ==
EOF
$ rbd --cluster site-b mirror pool peer bootstrap import --site-name site-b image-pool token
</pre></div>
</div>
</section>
<section id="id4">
<h3>手动增加互联的集群<a class="headerlink" href="#id4" title="Permalink to this heading"></a></h3>
<p>Cluster peers can be specified manually if desired or if the above bootstrap
commands are not available with the currently installed Ceph release.</p>
<p>The remote <code class="docutils literal notranslate"><span class="pre">rbd-mirror</span></code> daemon will need access to the local cluster to
perform mirroring. A new local Ceph user should be created for the remote
daemon to use. To <a class="reference external" href="../../rados/operations/user-management#add-a-user">创建一个 Ceph 用户</a>, with <code class="docutils literal notranslate"><span class="pre">ceph</span></code> specify the
<code class="docutils literal notranslate"><span class="pre">auth</span> <span class="pre">get-or-create</span></code> command, user name, monitor caps, and OSD caps:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ ceph auth get-or-create client.rbd-mirror-peer mon &#39;profile rbd-mirror-peer&#39; osd &#39;profile rbd&#39;
</pre></div>
</div>
<p>The resulting keyring should be copied to the other cluster’s <code class="docutils literal notranslate"><span class="pre">rbd-mirror</span></code>
daemon hosts if not using the Ceph monitor <code class="docutils literal notranslate"><span class="pre">config-key</span></code> store described below.</p>
<p>To manually add a mirroring peer Ceph cluster with <code class="docutils literal notranslate"><span class="pre">rbd</span></code>, specify the
<code class="docutils literal notranslate"><span class="pre">mirror</span> <span class="pre">pool</span> <span class="pre">peer</span> <span class="pre">add</span></code> command, the pool name, and a cluster specification:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">rbd</span> <span class="n">mirror</span> <span class="n">pool</span> <span class="n">peer</span> <span class="n">add</span> <span class="p">{</span><span class="n">pool</span><span class="o">-</span><span class="n">name</span><span class="p">}</span> <span class="p">{</span><span class="n">client</span><span class="o">-</span><span class="n">name</span><span class="p">}</span><span class="o">@</span><span class="p">{</span><span class="n">cluster</span><span class="o">-</span><span class="n">name</span><span class="p">}</span>
</pre></div>
</div>
<p>例如:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ rbd --cluster site-a mirror pool peer add image-pool client.rbd-mirror-peer@site-b
$ rbd --cluster site-b mirror pool peer add image-pool client.rbd-mirror-peer@site-a
</pre></div>
</div>
<p>By default, the <code class="docutils literal notranslate"><span class="pre">rbd-mirror</span></code> daemon needs to have access to a Ceph
configuration file located at <code class="docutils literal notranslate"><span class="pre">/etc/ceph/{cluster-name}.conf</span></code> that provides
the addresses of the peer cluster’s monitors, in addition to a keyring for
<code class="docutils literal notranslate"><span class="pre">{client-name}</span></code> located in the default or configured keyring search paths
(e.g. <code class="docutils literal notranslate"><span class="pre">/etc/ceph/{cluster-name}.{client-name}.keyring</span></code>).</p>
<p>Alternatively, the peer cluster’s monitor and/or client key can be securely
stored within the local Ceph monitor <code class="docutils literal notranslate"><span class="pre">config-key</span></code> store. To specify the
peer cluster connection attributes when adding a mirroring peer, use the
<code class="docutils literal notranslate"><span class="pre">--remote-mon-host</span></code> and <code class="docutils literal notranslate"><span class="pre">--remote-key-file</span></code> optionals. 例如:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ cat &lt;&lt;EOF &gt; remote-key-file
AQAeuZdbMMoBChAAcj++/XUxNOLFaWdtTREEsw==
EOF
$ rbd --cluster site-a mirror pool peer add image-pool client.rbd-mirror-peer@site-b --remote-mon-host 192.168.1.1,192.168.1.2 --remote-key-file remote-key-file
$ rbd --cluster site-a mirror pool info image-pool --all
Mode: pool
Peers:
  UUID                                 NAME   CLIENT                 MON_HOST                KEY
  587b08db-3d33-4f32-8af8-421e77abb081 site-b client.rbd-mirror-peer 192.168.1.1,192.168.1.2 AQAeuZdbMMoBChAAcj++/XUxNOLFaWdtTREEsw==
</pre></div>
</div>
</section>
<section id="id5">
<h3>删除互联的集群<a class="headerlink" href="#id5" title="Permalink to this heading"></a></h3>
<p>要用 <code class="docutils literal notranslate"><span class="pre">rbd</span></code> 删除镜像点 Ceph 集群，可指定 <code class="docutils literal notranslate"><span class="pre">mirror</span> <span class="pre">pool</span> <span class="pre">peer</span> <span class="pre">remove</span></code>
命令、以及互联点的 UUID （可用 <code class="docutils literal notranslate"><span class="pre">rbd</span> <span class="pre">mirror</span> <span class="pre">pool</span> <span class="pre">info</span></code> 命令找出）：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">rbd</span> <span class="n">mirror</span> <span class="n">pool</span> <span class="n">peer</span> <span class="n">remove</span> <span class="p">{</span><span class="n">pool</span><span class="o">-</span><span class="n">name</span><span class="p">}</span> <span class="p">{</span><span class="n">peer</span><span class="o">-</span><span class="n">uuid</span><span class="p">}</span>
</pre></div>
</div>
<p>例如：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ rbd --cluster site-a mirror pool peer remove image-pool 55672766-c02b-4729-8567-f13a66893445
$ rbd --cluster site-b mirror pool peer remove image-pool 60c0e299-b38f-4234-91f6-eed0a367be08
</pre></div>
</div>
</section>
<section id="id6">
<h3>数据存储池<a class="headerlink" href="#id6" title="Permalink to this heading"></a></h3>
<p>在目的集群创建映像时， <code class="docutils literal notranslate"><span class="pre">rbd-mirror</span></code> 这样选择数据集群：</p>
<ol class="arabic simple">
<li><p>如果目的集群已配置了一个默认的数据存储池（用
<code class="docutils literal notranslate"><span class="pre">rbd_default_data_pool</span></code> 配置选项），那就用它；</p></li>
<li><p>否则，如果源映像位于独立的数据存储池内，而且目的集群上也有同名的一个存储池，那就选用它；</p></li>
<li><p>如果上述二者都不可行，那就不会选中数据存储池。</p></li>
</ol>
</section>
</section>
<section id="id7">
<h2>映像配置<a class="headerlink" href="#id7" title="Permalink to this heading"></a></h2>
<p>不像存储池配置方式，映像配置只需要操作单个镜像点 Ceph 集群就行。</p>
<p>被镜像的 RBD 映像需指定为主、或非主的，这是映像的属性、不是存储池的。被指定为非主的映像不能被修改。</p>
<p>某一映像的镜像功能被开启时，它会被自动晋级为主映像（在存储池镜像模式为 <code class="docutils literal notranslate"><span class="pre">pool</span></code> 且映像开启了 journaling 映像功能时为隐式的；或者，如果存储池镜像模式为 <code class="docutils literal notranslate"><span class="pre">image</span></code> 时可以用 <code class="docutils literal notranslate"><span class="pre">rbd</span></code> 命令<a class="reference external" href="#enable-image-mirroring">显式地开启</a>）。</p>
<section id="id8">
<h3>启用基于映像的镜像<a class="headerlink" href="#id8" title="Permalink to this heading"></a></h3>
<p>如果映像所在存储池的镜像功能配置成了 <code class="docutils literal notranslate"><span class="pre">image</span></code> 模式，那就得显式地启用各个映像的镜像功能。可以用 <code class="docutils literal notranslate"><span class="pre">rbd</span></code> 的
<code class="docutils literal notranslate"><span class="pre">mirror</span> <span class="pre">image</span> <span class="pre">enable</span></code> 命令、再加上存储池、映像名和模式：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">rbd</span> <span class="n">mirror</span> <span class="n">image</span> <span class="n">enable</span> <span class="p">{</span><span class="n">pool</span><span class="o">-</span><span class="n">name</span><span class="p">}</span><span class="o">/</span><span class="p">{</span><span class="n">image</span><span class="o">-</span><span class="n">name</span><span class="p">}</span> <span class="p">{</span><span class="n">mode</span><span class="p">}</span>
</pre></div>
</div>
<p>The mirror image mode can either be <code class="docutils literal notranslate"><span class="pre">journal</span></code> or <code class="docutils literal notranslate"><span class="pre">snapshot</span></code>:</p>
<ul class="simple">
<li><p><strong>journal</strong> (default): When configured in <code class="docutils literal notranslate"><span class="pre">journal</span></code> mode, mirroring will
utilize the RBD journaling image feature to replicate the image contents. If
the RBD journaling image feature is not yet enabled on the image, it will be
automatically enabled.</p></li>
<li><p><strong>snapshot</strong>:  When configured in <code class="docutils literal notranslate"><span class="pre">snapshot</span></code> mode, mirroring will utilize
RBD image mirror-snapshots to replicate the image contents. Once enabled, an
initial mirror-snapshot will automatically be created. Additional RBD image
<a class="reference external" href="#create-image-mirror-snapshots">mirror-snapshots</a> can be created by the <code class="docutils literal notranslate"><span class="pre">rbd</span></code> command.</p></li>
</ul>
<p>例如：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ rbd --cluster site-a mirror image enable image-pool/image-1 snapshot
$ rbd --cluster site-a mirror image enable image-pool/image-2 journal
</pre></div>
</div>
</section>
<section id="journaling">
<h3>开启映像的 journaling 功能<a class="headerlink" href="#journaling" title="Permalink to this heading"></a></h3>
<p>RBD 镜像用 journaling 功能来保证复制的映像始终保持崩溃一致性。使用 <code class="docutils literal notranslate"><span class="pre">image</span></code> 镜像模式时，在此映像上启用镜像的同时就会自动启用日志功能；使用 <code class="docutils literal notranslate"><span class="pre">pool</span></code> 镜像模式时，必须先启用
RBD 映像日志功能，映像才能被镜像到对点集群。此功能可在创建映像时打开，即执行 <code class="docutils literal notranslate"><span class="pre">rbd</span></code> 命令时加上
<code class="docutils literal notranslate"><span class="pre">--image-feature</span> <span class="pre">exclusive-lock,journaling</span></code> 选项。</p>
<p>另外，在已存在的 RBD 映像上也可以动态地开启 journaling 功能。要用 <code class="docutils literal notranslate"><span class="pre">rbd</span></code> 命令开启 journaling 功能可指定 <code class="docutils literal notranslate"><span class="pre">feature</span> <span class="pre">enable</span></code>
命令、存储池名和映像名、以及功能名：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">rbd</span> <span class="n">feature</span> <span class="n">enable</span> <span class="p">{</span><span class="n">pool</span><span class="o">-</span><span class="n">name</span><span class="p">}</span><span class="o">/</span><span class="p">{</span><span class="n">image</span><span class="o">-</span><span class="n">name</span><span class="p">}</span> <span class="p">{</span><span class="n">feature</span><span class="o">-</span><span class="n">name</span><span class="p">}</span>
</pre></div>
</div>
<p>例如：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ rbd --cluster site-a feature enable image-pool/image-1 journaling
</pre></div>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>journaling 功能依赖于 exclusive-lock （互斥锁）功能。如果 exclusive-lock 功能还没启用，应该先启用它、再启用 journaling 功能。</p>
</div>
<div class="admonition tip">
<p class="admonition-title">Tip</p>
<p>你可以让所有新映像默认启用日志功能，把
<code class="docutils literal notranslate"><span class="pre">rbd</span> <span class="pre">default</span> <span class="pre">features</span> <span class="pre">=</span> <span class="pre">125</span></code> 写入配置文件即可。</p>
</div>
<div class="admonition tip">
<p class="admonition-title">Tip</p>
<p><code class="docutils literal notranslate"><span class="pre">rbd-mirror</span></code> tunables are set by default to values suitable for
mirroring an entire pool.  When using <code class="docutils literal notranslate"><span class="pre">rbd-mirror</span></code> to migrate single
volumes been clusters you may achieve substantial performance gains
by setting <code class="docutils literal notranslate"><span class="pre">rbd_mirror_journal_max_fetch_bytes=33554432</span></code> and
<code class="docutils literal notranslate"><span class="pre">rbd_journal_max_payload_bytes=8388608</span></code> within the <code class="docutils literal notranslate"><span class="pre">[client]</span></code> config
section of the local or centralized configuration.  Note that these
settings may allow <code class="docutils literal notranslate"><span class="pre">rbd-mirror</span></code> to present a substantial write workload
to the destination cluster:  monitor cluster performance closely during
migrations and test carefully before running multiple migrations in parallel.</p>
</div>
</section>
<section id="create-image-mirror-snapshots">
<h3>Create Image Mirror-Snapshots<a class="headerlink" href="#create-image-mirror-snapshots" title="Permalink to this heading"></a></h3>
<p>When using snapshot-based mirroring, mirror-snapshots will need to be created
whenever it is desired to mirror the changed contents of the RBD image. To
create a mirror-snapshot manually with <code class="docutils literal notranslate"><span class="pre">rbd</span></code>, specify the
<code class="docutils literal notranslate"><span class="pre">mirror</span> <span class="pre">image</span> <span class="pre">snapshot</span></code> command along with the pool and image name:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">rbd</span> <span class="n">mirror</span> <span class="n">image</span> <span class="n">snapshot</span> <span class="p">{</span><span class="n">pool</span><span class="o">-</span><span class="n">name</span><span class="p">}</span><span class="o">/</span><span class="p">{</span><span class="n">image</span><span class="o">-</span><span class="n">name</span><span class="p">}</span>
</pre></div>
</div>
<p>例如:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ rbd --cluster site-a mirror image snapshot image-pool/image-1
</pre></div>
</div>
<p>By default up to <code class="docutils literal notranslate"><span class="pre">5</span></code> mirror-snapshots will be created per-image. The most
recent mirror-snapshot is automatically pruned if the limit is reached.
The limit can be overridden via the <code class="docutils literal notranslate"><span class="pre">rbd_mirroring_max_mirroring_snapshots</span></code>
configuration option if required. Additionally, mirror-snapshots are
automatically deleted when the image is removed or when mirroring is disabled.</p>
<p>Mirror-snapshots can also be automatically created on a periodic basis if
mirror-snapshot schedules are defined. The mirror-snapshot can be scheduled
globally, per-pool, or per-image levels. Multiple mirror-snapshot schedules can
be defined at any level, but only the most-specific snapshot schedules that
match an individual mirrored image will run.</p>
<p>To create a mirror-snapshot schedule with <code class="docutils literal notranslate"><span class="pre">rbd</span></code>, specify the
<code class="docutils literal notranslate"><span class="pre">mirror</span> <span class="pre">snapshot</span> <span class="pre">schedule</span> <span class="pre">add</span></code> command along with an optional pool or
image name; interval; and optional start time:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">rbd</span> <span class="n">mirror</span> <span class="n">snapshot</span> <span class="n">schedule</span> <span class="n">add</span> <span class="p">[</span><span class="o">--</span><span class="n">pool</span> <span class="p">{</span><span class="n">pool</span><span class="o">-</span><span class="n">name</span><span class="p">}]</span> <span class="p">[</span><span class="o">--</span><span class="n">image</span> <span class="p">{</span><span class="n">image</span><span class="o">-</span><span class="n">name</span><span class="p">}]</span> <span class="p">{</span><span class="n">interval</span><span class="p">}</span> <span class="p">[{</span><span class="n">start</span><span class="o">-</span><span class="n">time</span><span class="p">}]</span>
</pre></div>
</div>
<p>The <code class="docutils literal notranslate"><span class="pre">interval</span></code> can be specified in days, hours, or minutes using <code class="docutils literal notranslate"><span class="pre">d</span></code>, <code class="docutils literal notranslate"><span class="pre">h</span></code>,
<code class="docutils literal notranslate"><span class="pre">m</span></code> suffix respectively. The optional <code class="docutils literal notranslate"><span class="pre">start-time</span></code> can be specified using
the ISO 8601 time format. 例如:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ rbd --cluster site-a mirror snapshot schedule add --pool image-pool 24h 14:00:00-05:00
$ rbd --cluster site-a mirror snapshot schedule add --pool image-pool --image image1 6h
</pre></div>
</div>
<p>To remove a mirror-snapshot schedules with <code class="docutils literal notranslate"><span class="pre">rbd</span></code>, specify the
<code class="docutils literal notranslate"><span class="pre">mirror</span> <span class="pre">snapshot</span> <span class="pre">schedule</span> <span class="pre">remove</span></code> command with options that match the
corresponding <code class="docutils literal notranslate"><span class="pre">add</span></code> schedule command.</p>
<p>To list all snapshot schedules for a specific level (global, pool, or image)
with <code class="docutils literal notranslate"><span class="pre">rbd</span></code>, specify the <code class="docutils literal notranslate"><span class="pre">mirror</span> <span class="pre">snapshot</span> <span class="pre">schedule</span> <span class="pre">ls</span></code> command along with
an optional pool or image name. Additionally, the <code class="docutils literal notranslate"><span class="pre">--recursive</span></code> option can
be specified to list all schedules at the specified level and below. For
example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ rbd --cluster site-a mirror snapshot schedule ls --pool image-pool --recursive
POOL        NAMESPACE IMAGE  SCHEDULE
image-pool  -         -      every 1d starting at 14:00:00-05:00
image-pool            image1 every 6h
</pre></div>
</div>
<p>To view the status for when the next snapshots will be created for
snapshot-based mirroring RBD images with <code class="docutils literal notranslate"><span class="pre">rbd</span></code>, specify the
<code class="docutils literal notranslate"><span class="pre">mirror</span> <span class="pre">snapshot</span> <span class="pre">schedule</span> <span class="pre">status</span></code> command along with an optional pool or
image name:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">rbd</span> <span class="n">mirror</span> <span class="n">snapshot</span> <span class="n">schedule</span> <span class="n">status</span> <span class="p">[</span><span class="o">--</span><span class="n">pool</span> <span class="p">{</span><span class="n">pool</span><span class="o">-</span><span class="n">name</span><span class="p">}]</span> <span class="p">[</span><span class="o">--</span><span class="n">image</span> <span class="p">{</span><span class="n">image</span><span class="o">-</span><span class="n">name</span><span class="p">}]</span>
</pre></div>
</div>
<p>例如:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ rbd --cluster site-a mirror snapshot schedule status
SCHEDULE TIME       IMAGE
2020-02-26 18:00:00 image-pool/image1
</pre></div>
</div>
</section>
<section id="id9">
<h3>禁用映像的镜像功能<a class="headerlink" href="#id9" title="Permalink to this heading"></a></h3>
<p>要禁用某一映像的镜像功能，可用 <code class="docutils literal notranslate"><span class="pre">rbd</span></code> 、加
<code class="docutils literal notranslate"><span class="pre">mirror</span> <span class="pre">image</span> <span class="pre">disable</span></code> 命令，再加上存储池名和映像名：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">rbd</span> <span class="n">mirror</span> <span class="n">image</span> <span class="n">disable</span> <span class="p">{</span><span class="n">pool</span><span class="o">-</span><span class="n">name</span><span class="p">}</span><span class="o">/</span><span class="p">{</span><span class="n">image</span><span class="o">-</span><span class="n">name</span><span class="p">}</span>
</pre></div>
</div>
<p>例如：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ rbd --cluster site-a mirror image disable image-pool/image-1
</pre></div>
</div>
</section>
<section id="id10">
<h3>映像的晋级和降级<a class="headerlink" href="#id10" title="Permalink to this heading"></a></h3>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>译者注： promotion 翻译为晋级， demotion 翻译为降级。</p>
</div>
<p>在故障切换时，主映像标记要被挪到互联 Ceph 集群的对应映像上，到主映像的访问应该停止（例如关闭相应的 VM 、或者从 VM 里移除关联设备），降级当前的主映像，晋级新的主映像，然后在另一个集群上恢复访问。</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>RBD 仅仅提供了实现故障有序切换所必需的工具集，你仍需要一套外部机制来保障整个故障切换进程的顺利进行（例如降级前先关闭映像）。</p>
</div>
<p>要用 <code class="docutils literal notranslate"><span class="pre">rbd</span></code> 命令把某一映像降级成非主的，用
<code class="docutils literal notranslate"><span class="pre">mirror</span> <span class="pre">image</span> <span class="pre">demote</span></code> 命令，加上存储池名和映像名：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">rbd</span> <span class="n">mirror</span> <span class="n">image</span> <span class="n">demote</span> <span class="p">{</span><span class="n">pool</span><span class="o">-</span><span class="n">name</span><span class="p">}</span><span class="o">/</span><span class="p">{</span><span class="n">image</span><span class="o">-</span><span class="n">name</span><span class="p">}</span>
</pre></div>
</div>
<p>例如：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ rbd --cluster site-a mirror image demote image-pool/image-1
</pre></div>
</div>
<p>要用 <code class="docutils literal notranslate"><span class="pre">rbd</span></code> 命令把存储池内的所有映像降级为非主的，可用
<code class="docutils literal notranslate"><span class="pre">mirror</span> <span class="pre">pool</span> <span class="pre">demote</span></code> 命令，加上存储池名：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">rbd</span> <span class="n">mirror</span> <span class="n">pool</span> <span class="n">demote</span> <span class="p">{</span><span class="n">pool</span><span class="o">-</span><span class="n">name</span><span class="p">}</span>
</pre></div>
</div>
<p>例如：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ rbd --cluster site-a mirror pool demote image-pool
</pre></div>
</div>
<p>要用 <code class="docutils literal notranslate"><span class="pre">rbd</span></code> 把某一映像晋级为主的，可用 <code class="docutils literal notranslate"><span class="pre">mirror</span> <span class="pre">image</span> <span class="pre">promote</span></code>
命令、加存储池名和映像名：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">rbd</span> <span class="n">mirror</span> <span class="n">image</span> <span class="n">promote</span> <span class="p">[</span><span class="o">--</span><span class="n">force</span><span class="p">]</span> <span class="p">{</span><span class="n">pool</span><span class="o">-</span><span class="n">name</span><span class="p">}</span><span class="o">/</span><span class="p">{</span><span class="n">image</span><span class="o">-</span><span class="n">name</span><span class="p">}</span>
</pre></div>
</div>
<p>例如：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ rbd --cluster site-b mirror image promote image-pool/image-1
</pre></div>
</div>
<p>要用 <code class="docutils literal notranslate"><span class="pre">rbd</span></code> 命令把存储池内的所有映像晋级为主的，可用
<code class="docutils literal notranslate"><span class="pre">mirror</span> <span class="pre">pool</span> <span class="pre">promote</span></code> 命令，加上存储池名：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">rbd</span> <span class="n">mirror</span> <span class="n">pool</span> <span class="n">promote</span> <span class="p">[</span><span class="o">--</span><span class="n">force</span><span class="p">]</span> <span class="p">{</span><span class="n">pool</span><span class="o">-</span><span class="n">name</span><span class="p">}</span>
</pre></div>
</div>
<p>例如：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ rbd --cluster site-a mirror pool promote image-pool
</pre></div>
</div>
<div class="admonition tip">
<p class="admonition-title">Tip</p>
<p>由于主、非主状态是基于单个映像的，所以有可能让两个集群分摊 IO 负载、并实现故障切换、故障恢复。</p>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>晋级可用 <code class="docutils literal notranslate"><span class="pre">--force</span></code> 选项强制施行。在降级未能传达到互联的 Ceph 集群时（例如 Ceph 集群故障，通讯中断），就需要强制晋级。这会导致两个对等点形成裂脑（ split-brain ），并且这两个映像无法回到同步状态，只能通过<a class="reference external" href="#force-image-resync">强制重新同步命令</a>恢复同步。</p>
</div>
</section>
<section id="id11">
<h3>强制重新同步映像<a class="headerlink" href="#id11" title="Permalink to this heading"></a></h3>
<p>如果 <code class="docutils literal notranslate"><span class="pre">rbd-mirror</span></code> 守护进程探测到了裂脑事件，它就不会再企图镜像受影响的映像，除非已纠正。要恢复一个映像的镜像，首先找出过期的映像、并<a class="reference external" href="#image-promotion-and-demotion">降级此映像</a>，然后向主映像发出一个重新同步的请求。要用 <code class="docutils literal notranslate"><span class="pre">rbd</span></code> 请求重新同步映像，可用
<code class="docutils literal notranslate"><span class="pre">mirror</span> <span class="pre">image</span> <span class="pre">resync</span></code> 命令、加上存储池名和映像名：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">rbd</span> <span class="n">mirror</span> <span class="n">image</span> <span class="n">resync</span> <span class="p">{</span><span class="n">pool</span><span class="o">-</span><span class="n">name</span><span class="p">}</span><span class="o">/</span><span class="p">{</span><span class="n">image</span><span class="o">-</span><span class="n">name</span><span class="p">}</span>
</pre></div>
</div>
<p>例如：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ rbd mirror image resync image-pool/image-1
</pre></div>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p><code class="docutils literal notranslate"><span class="pre">rbd</span></code> 命令仅仅把这个映像标记为需要重新同步。本地集群的 <code class="docutils literal notranslate"><span class="pre">rbd-mirror</span></code> 守护进程负责异步地重新同步。</p>
</div>
</section>
</section>
<section id="id12">
<h2>镜像状态<a class="headerlink" href="#id12" title="Permalink to this heading"></a></h2>
<p>每一个主的、被镜像的映像都存储了互联集群的复制状态，这些状态信息可用 <code class="docutils literal notranslate"><span class="pre">mirror</span> <span class="pre">image</span> <span class="pre">status</span></code> 和 <code class="docutils literal notranslate"><span class="pre">mirror</span> <span class="pre">pool</span> <span class="pre">status</span></code>
命令查看。</p>
<p>要用 <code class="docutils literal notranslate"><span class="pre">rbd</span></code> 查看映像的镜像状态，可用 <code class="docutils literal notranslate"><span class="pre">mirror</span> <span class="pre">image</span> <span class="pre">status</span></code>
命令、加上存储池名、映像名：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">rbd</span> <span class="n">mirror</span> <span class="n">image</span> <span class="n">status</span> <span class="p">{</span><span class="n">pool</span><span class="o">-</span><span class="n">name</span><span class="p">}</span><span class="o">/</span><span class="p">{</span><span class="n">image</span><span class="o">-</span><span class="n">name</span><span class="p">}</span>
</pre></div>
</div>
<p>例如：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ rbd mirror image status image-pool/image-1
</pre></div>
</div>
<p>要用 <code class="docutils literal notranslate"><span class="pre">rbd</span></code> 命令查看存储池的镜像汇总状态，可用
<code class="docutils literal notranslate"><span class="pre">mirror</span> <span class="pre">pool</span> <span class="pre">status</span></code> 命令、加上存储池名：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">rbd</span> <span class="n">mirror</span> <span class="n">pool</span> <span class="n">status</span> <span class="p">{</span><span class="n">pool</span><span class="o">-</span><span class="n">name</span><span class="p">}</span>
</pre></div>
</div>
<p>例如：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ rbd mirror pool status image-pool
</pre></div>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>给 <code class="docutils literal notranslate"><span class="pre">mirror</span> <span class="pre">pool</span> <span class="pre">status</span></code> 命令加上 <code class="docutils literal notranslate"><span class="pre">--verbose</span></code>
选项，它还会额外输出此存储池内每一个映像的镜像状态细节。</p>
</div>
</section>
<section id="rbd-mirror">
<h2>rbd-mirror 守护进程<a class="headerlink" href="#rbd-mirror" title="Permalink to this heading"></a></h2>
<p>两边的 <code class="docutils literal notranslate"><span class="pre">rbd-mirror</span></code> 守护进程负责监视远端的、互联集群的映像日志，并在本地集群回放这些日志事件。 RBD 映像的 journaling 功能会在映像内按其发生顺序记录所有变更，这样可确保远端映像的崩溃一致镜像在本地可用。</p>
<p><code class="docutils literal notranslate"><span class="pre">rbd-mirror</span></code> 守护进程随可选的 <code class="docutils literal notranslate"><span class="pre">rbd-mirror</span></code> 发行版软件包提供。</p>
<div class="admonition important">
<p class="admonition-title">Important</p>
<p>每个 <code class="docutils literal notranslate"><span class="pre">rbd-mirror</span></code> 守护进程都要求能同时连接两边的集群。</p>
</div>
<div class="admonition warning">
<p class="admonition-title">Warning</p>
<p>小于 Luminous 的版本：每个 Ceph 集群只能运行一个
<code class="docutils literal notranslate"><span class="pre">rbd-mirror</span></code> 守护进程。</p>
</div>
<p>每个 <code class="docutils literal notranslate"><span class="pre">rbd-mirror</span></code> 守护进程都应该使用唯一的 Ceph 用户 ID 。要<cite>_创建一个 Ceph 用户</cite>，用 <code class="docutils literal notranslate"><span class="pre">ceph</span></code> 命令，加上
<code class="docutils literal notranslate"><span class="pre">auth</span> <span class="pre">get-or-create</span></code> 、用户名、监视器能力、和 OSD 能力：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span> <span class="n">auth</span> <span class="n">get</span><span class="o">-</span><span class="ow">or</span><span class="o">-</span><span class="n">create</span> <span class="n">client</span><span class="o">.</span><span class="n">rbd</span><span class="o">-</span><span class="n">mirror</span><span class="o">.</span><span class="p">{</span><span class="n">unique</span> <span class="nb">id</span><span class="p">}</span> <span class="n">mon</span> <span class="s1">&#39;profile rbd-mirror&#39;</span> <span class="n">osd</span> <span class="s1">&#39;profile rbd&#39;</span>
</pre></div>
</div>
<p><code class="docutils literal notranslate"><span class="pre">rbd-mirror</span></code> 守护进程可以用 <code class="docutils literal notranslate"><span class="pre">systemd</span></code> 管理，用户 ID 作为守护进程例程：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">systemctl</span> <span class="n">enable</span> <span class="n">ceph</span><span class="o">-</span><span class="n">rbd</span><span class="o">-</span><span class="n">mirror</span><span class="nd">@rbd</span><span class="o">-</span><span class="n">mirror</span><span class="o">.</span><span class="p">{</span><span class="n">unique</span> <span class="nb">id</span><span class="p">}</span>
</pre></div>
</div>
<p><code class="docutils literal notranslate"><span class="pre">rbd-mirror</span></code> 也能放在前台运行，命令如下：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">rbd</span><span class="o">-</span><span class="n">mirror</span> <span class="o">-</span><span class="n">f</span> <span class="o">--</span><span class="n">log</span><span class="o">-</span><span class="n">file</span><span class="o">=</span><span class="p">{</span><span class="n">log_path</span><span class="p">}</span>
</pre></div>
</div>
</section>
</section>



<div id="support-the-ceph-foundation" class="admonition note">
  <p class="first admonition-title">Brought to you by the Ceph Foundation</p>
  <p class="last">The Ceph Documentation is a community resource funded and hosted by the non-profit <a href="https://ceph.io/en/foundation/">Ceph Foundation</a>. If you would like to support this and our other efforts, please consider <a href="https://ceph.io/en/foundation/join/">joining now</a>.</p>
</div>


           </div>
           
          </div>
          <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
        <a href="../rbd-exclusive-locks/" class="btn btn-neutral float-left" title="RBD Exclusive Locks" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
        <a href="../rbd-live-migration/" class="btn btn-neutral float-right" title="映像在线迁移" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
    </div>

  <hr/>

  <div role="contentinfo">
    <p>&#169; Copyright 2016, Ceph authors and contributors. Licensed under Creative Commons Attribution Share Alike 3.0 (CC-BY-SA-3.0).</p>
  </div>

   

</footer>
        </div>
      </div>

    </section>

  </div>
  

  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
   

</body>
</html>